﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace UIObjects
{
    public class ExceptionMemento
    {
        /// <summary>
        /// Gets or sets the name of the type of <see cref="Exception"/>.
        /// </summary>
        /// <value>The name of the type.</value>
        public string TypeName { get; set; }
        public string Message { get; set; }
        public string Source { get; set; }
        public string StackTrace { get; set; }
        public string HelpLink { get; set; }

        /// <summary>
        /// Initializes a new instance of the <see cref="ExceptionMemento"/> class.
        /// </summary>
        public ExceptionMemento()
        {
        }

        public ExceptionMemento(Exception exception)
        {
            if (exception == null)
            {
                throw new ArgumentNullException("exception");
            }
            TypeName = exception.GetType().AssemblyQualifiedName;
            Message = exception.Message;
            StackTrace = exception.StackTrace;
        }

        public override string ToString()
        {
            return string.Format("{0}  Message: {1} HelpLink: {2}{3}StackTrace: {4}",
                TypeName,
                Message,
                HelpLink,
                Environment.NewLine,
                StackTrace);
        }
    }
}
